<?php
// +----------------------------------------------------------------------
// | HkCms 用户验证规则
// +----------------------------------------------------------------------
// | Copyright (c) 2012-2019 http://www.hkcms.cn, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 广州恒企教育科技有限公司 <admin@hkcms.cn>
// +----------------------------------------------------------------------

namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username' => 'require|unique:User',
        'nickname' => 'require',
        'role_id' => 'require',
        'password' => 'require',
        'pwdconfirm' => 'require|confirm:password',
        'email' => 'email',
        'status' => 'in:0,1',
    ];

    protected $message  =   [
        'username.require' => '用户名不能为空！',
        'nickname.require' => '真实姓名不能为空！',
        'role_id.require'  => '帐号所属角色不能为空！',
        'password.require' => '密码不能为空！',
        'pwdconfirm.confirm' => '两次输入的密码不一样！',    
        'username.unique' => '帐号名称已经存在！',
        'status.in:0,1' => '状态错误，状态只能是1或者0！',
        'email.email' => '邮箱地址有误！',
    ];

    protected $scene = [
        'edit'  =>  ['nickname','role_id','email','status'],
        'myinfo'      =>  ['nickname','email','remark']
    ];
}